# Maintainer: Ray Griffin <rorgoroth-dev@outlook.com>

_realname=jpegoptim
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.4.6
pkgrel=1
pkgdesc="Utility to optimize jpeg files"
arch=('any')
url="https://www.kokkonen.net/tjko/projects.html"
license=('GPL')
depends=("${MINGW_PACKAGE_PREFIX}-libjpeg-turbo")
source=("https://www.kokkonen.net/tjko/src/${_realname}-${pkgver}.tar.gz"{,.sig})
validpgpkeys=('9168CD7A2F0AAB0679D09BBA9D08A80CED908D6A')
sha256sums=('88b1eb64c2a33a2f013f068df8b0331f42c019267401ae3fa28e3277403a5ab7'
            'SKIP')

build() {
  cd "${srcdir}/${_realname}-${pkgver}"
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  cp -rf ../${_realname}-${pkgver}/* "${srcdir}"/build-${CARCH}
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"

  install -Dm644 ${srcdir}/${_realname}-${pkgver}/COPYING ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
